//
//  CLTabBarViewController.m
//  weibo-OC
//
//  Created by Oboe_b on 16/8/29.
//  Copyright © 2016年 Oboe_b. All rights reserved.
//

#import "CLNavigationViewController.h"
#import "CLTabBarViewController.h"
#import "CLTabBar.h"
#import "CLComposeView.h"

#import "OrderTableViewController.h"
#import "AssetTableViewController.h"
#import "MineTableViewController.h"
#import "AssetViewController.h"
#import "AssetnewViewController.h"
#import "DealViewController.h"
#import "AppDelegate.h"

@interface CLTabBarViewController ()

@end

@implementation CLTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
 
    if (is_Ic) {
        [self addicChildViewController];
    } else {
        [self customtabbar];
        [self adducChildViewController];
    }
}

#pragma mark - 自定义Tabbar
- (void)customtabbar {
    
    // 自定义TabBar
    CLTabBar *tabBar = [[CLTabBar alloc] init];
    
    tabBar.composeButtonClick = ^(UIButton *sender){
        sender.transform=CGAffineTransformMakeRotation(M_PI/4);
        NSLog(@"点击按钮,弹出菜单");
        CLComposeView *composeView = [[CLComposeView alloc] init];
        [composeView showWithController:self];
        
        composeView.disMissBlock = ^(NSInteger index) {
            sender.transform=CGAffineTransformMakeRotation(0);
            
            //弹出控制器..
        };
    };
    
    [self setValue:tabBar forKey:@"tabBar"];
}

//用户
-  (void)adducChildViewController {
    
    //交易
    DealViewController *dealVC = [DealViewController new];
    OrderTableViewController *orderTVC = [[OrderTableViewController alloc] init];
    AssetnewViewController *new = [AssetnewViewController new];
    MineTableViewController *mineTVC =[[UIStoryboard storyboardWithName:@"MineTableViewController" bundle:nil] instantiateViewControllerWithIdentifier:@"mineTableViewController"];
    
     [self addChildViewController:dealVC title:@"交易" imageCode:@"\U0000e63b"];
     [self addChildViewController:orderTVC title:@"订单" imageCode:@"\U0000e623"];
     [self addChildViewController:new title:@"资产" imageCode:@"\U0000e608"];
     [self addChildViewController: mineTVC title:@"我的" imageCode:@"\U0000e634"];
}
//中介
-  (void)addicChildViewController { //中介APP 只有订单 资产 我的
    
    //交易
    OrderTableViewController *orderTVC = [[OrderTableViewController alloc] init];
    AssetnewViewController *new = [AssetnewViewController new];
    MineTableViewController *mineTVC =[[UIStoryboard storyboardWithName:@"MineTableViewController" bundle:nil] instantiateViewControllerWithIdentifier:@"mineTableViewController"];
    
    [self addChildViewController:orderTVC title:@"订单" imageCode:@"\U0000e623"];
    [self addChildViewController:new title:@"资产" imageCode:@"\U0000e608"];
    [self addChildViewController: mineTVC title:@"我的" imageCode:@"\U0000e634"];
}

- (void)addChildViewController:(UIViewController *)vc title:(NSString *)title imageCode:(NSString  *)code {
    
    vc.tabBarItem.title = title;

    vc.tabBarItem.image = [UIImage iconWithInfo:TBCityIconInfoMake(code, 28,  [UIColor colorWithRed:199/255.0 green:199/255.0 blue:205/255.0 alpha:1/1.0])];
 
    vc.tabBarItem.selectedImage = [UIImage iconWithInfo:TBCityIconInfoMake(code, 28,  [UIColor colorWithRed:0/255.0 green:151/255.0 blue:255/255.0 alpha:1/1.0])];
    

    
    CLNavigationViewController *navController = [[CLNavigationViewController alloc] initWithRootViewController:vc];
    
    [self addChildViewController:navController];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
